←Select platform

SearchRegistrationMarksCommandData Constructor(int,int,int,int,LeadRect,int,LeadPoint[],RegistrationMarkCommandType)

Summary
Initializes a new SearchRegistrationMarksCommandData class object with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithWidth:(NSUInteger)width height:(NSUInteger)height minimumScale:(NSUInteger)minimumScale maximumScale:(NSUInteger)maximumScale rectangle:(LeadRect)rectangle searchMarkCount:(NSUInteger)searchMarkCount markDetectedPoints:(NSArray<NSValue *> *)markDetectedPoints type:(LTRegistrationMarkCommandType)type NS_DESIGNATED_INITIALIZER; 
public SearchRegistrationMarksCommandData( 
   int width, 
   int height, 
   int minimumScale, 
   int maximumScale, 
   LeadRect rectangle, 
   int searchMarkCount, 
   LeadPoint[] markDetectedPoints, 
   RegistrationMarkCommandType type 
); 
) 

Parameters

width
Registration mark width, in pixels. This parameter accepts only positive values.

height
Registration mark height, in pixels. This parameter accepts only positive values.

minimumScale
Minimum registration mark scale to be detected. This is a percentage. It must not exceed maximumScale. This parameter accepts only positive values.

maximumScale
Maximum registration mark scale to be detected. This is a percentage. It must not be lower than minimumScale. This parameter accepts only positive values.

rectangle
The area to be searched for registration marks (in pixels).

searchMarkCount
Number of registration marks expected inside the search area. This parameter accepts only positive values.

markDetectedPoints
Array to be filled with the location points of the detected registration marks. SearchRegistrationMarksCommand will fill the first MarkDetectedCount elements in this array.

type
Registration mark type.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void ApplyTransformationParametersConstructorExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "RGSRef.cmp")); 
 
   // Prepare the command 
   RasterImage tempImage = image; 
   try 
   { 
      tempImage = image.Clone(); 
      if (tempImage.HasRegion) 
         tempImage.MakeRegionEmpty(); 
      if (image.HasRegion) 
         image.MakeRegionEmpty(); 
      SearchRegistrationMarksCommandData[] rmData = new SearchRegistrationMarksCommandData[3]; 
 
      // Mark1 
      rmData[0] = new SearchRegistrationMarksCommandData(); 
      rmData[0].Rectangle = new LeadRect(680, 20, 941 - 680, 218 - 20); 
      rmData[0].MarkDetectedPoints = new LeadPoint[1]; 
      rmData[0].Width = 31; 
      rmData[0].Height = 29; 
      rmData[0].Type = RegistrationMarkCommandType.TShape; 
      rmData[0].MinimumScale = 90; 
      rmData[0].MaximumScale = 110; 
      rmData[0].SearchMarkCount = 1; 
 
      // Mark2 
      rmData[1] = new SearchRegistrationMarksCommandData(); 
      rmData[1].Rectangle = new LeadRect(665, 790, 899 - 665, 961 - 790); 
      rmData[1].MarkDetectedPoints = new LeadPoint[1]; 
      rmData[1].Width = 31; 
      rmData[1].Height = 29; 
      rmData[1].Type = RegistrationMarkCommandType.TShape; 
      rmData[1].MinimumScale = 90; 
      rmData[1].MaximumScale = 110; 
      rmData[1].SearchMarkCount = 1; 
 
      // Mark3 
      rmData[2] = new SearchRegistrationMarksCommandData(31, 29, 90, 110, new LeadRect(7, 1073, 298 - 7, 1246 - 1073), 1, new LeadPoint[1], RegistrationMarkCommandType.TShape); 
      SearchRegistrationMarksCommand command1 = new SearchRegistrationMarksCommand(); 
      command1.SearchMarks = rmData; 
      command1.Run(image); 
 
      if ((rmData[2].MarkDetectedCount != 1) || (rmData[1].MarkDetectedCount != 1) || (rmData[0].MarkDetectedCount != 1)) 
         return; 
 
      LeadPoint[] original = 
         { 
            new LeadPoint(81400, 11300), 
            new LeadPoint(78600, 87400), 
            new LeadPoint(14300, 115400) 
         }; 
 
      LeadPoint[] detected = 
         { 
            rmData[0].MarkDetectedPoints[0], 
            rmData[1].MarkDetectedPoints[0], 
            rmData[2].MarkDetectedPoints[0] 
         }; 
 
      // Find center of mass for detected registration marks in the transformed image 
      LeadPoint[] transformed = CoreUtilities.GetRegistrationMarksCenterMass(image, detected); 
      // Find transformation parameters 
      TransformationParameters parameters = CoreUtilities.GetTransformationParameters(image, original, transformed); 
      // Apply transformation parameters to correct the image 
      ApplyTransformationParametersCommand applyCommand = new ApplyTransformationParametersCommand(); 
      applyCommand.XTranslation = parameters.XTranslation; 
      applyCommand.YTranslation = parameters.YTranslation; 
      applyCommand.Angle = parameters.Angle; 
      applyCommand.XScale = parameters.XScale; 
      applyCommand.YScale = parameters.YScale; 
      applyCommand.Flags = ApplyTransformationParametersCommandFlags.Normal; 
      applyCommand.Run(tempImage); 
   } 
   catch (Exception exception) 
   { 
      MessageBox.Show(exception.Message); 
   } 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.11.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.